
     local blankPlayerstats = {agility = 1, agilityexp = 0, acrobatics = 1, acrobaticsexp = 0, barter = 1, barterexp = 0, defense = 1, defenseexp = 0, respect = 0}


     //LocalPlayer():GetTable().Playerstats = blankPlayerstats
     local function statsPaint()
          //local agility = LocalPlayer():GetTable().Playerstats.agility or 1
          if not LocalPlayer():GetTable().Playerstats then LocalPlayer():GetTable().Playerstats = blankPlayerstats end

          local agilityexp = LocalPlayer():GetTable().Playerstats.agilityexp or 1
          local agility = LocalPlayer():GetTable().Playerstats.agility or 1
          local agtexpneeded = (agility*10)^1.6
          local DrawAgility = math.Min(agilityexp / agtexpneeded, 1)

          local acrobaticsexp = LocalPlayer():GetTable().Playerstats.acrobaticsexp or 1
          local acrobatics = LocalPlayer():GetTable().Playerstats.acrobatics or 1
          local acbexpneeded = (acrobatics*10)^1.6
          local DrawAcrobatics = math.Min(acrobaticsexp / acbexpneeded, 1)

          local defenseexp = LocalPlayer():GetTable().Playerstats.defenseexp or 1
          local defense = LocalPlayer():GetTable().Playerstats.defense or 1
          local defexpneeded = (defense*10)^1.6
          local DrawDefense = math.Min(defenseexp / defexpneeded, 1)

          local XPlace = 0
          local XOffscreen = 5
          local YPlace = ScrH()-110
          local YSpacer = 2
          local MaxLength = 170
          local YSize=18
          local border=2
          local gradient = Material( "gui/gradient" )
          
          draw.RoundedBox(4, -XOffscreen, YPlace-border, MaxLength+border+XOffscreen, YSize*3+YSpacer*2+border*2, Color(100,100,100,220))

          draw.RoundedBox(2, XPlace-XOffscreen, YPlace, MaxLength+XOffscreen, YSize, Color(0,0,0,255))
          draw.RoundedBox(0, XPlace, YPlace+border, (MaxLength-border)*DrawAgility, YSize-border*2, Color(0,200,50,222))

          surface.SetMaterial( gradient )
          surface.SetDrawColor(0, 0, 0, 255)
          surface.DrawTexturedRectRotated(MaxLength/2, YPlace+(YSize*1+YSpacer*1)-YSize/2-YSpacer, YSize, MaxLength, 90 )
          
          draw.RoundedBox(2, XPlace-XOffscreen, YPlace+YSize+YSpacer, MaxLength+XOffscreen, YSize, Color(0,0,0,255))
          draw.RoundedBox(0, XPlace, YPlace+YSize+YSpacer+border, (MaxLength-border)*DrawAcrobatics, YSize-border*2, Color(200,200,0,222))

          surface.SetMaterial( gradient )
          surface.SetDrawColor(0, 0, 0, 255)
          surface.DrawTexturedRectRotated(MaxLength/2, YPlace+(YSize*2+YSpacer*2)-YSize/2-YSpacer, YSize, MaxLength, 90 )

          draw.RoundedBox(2, XPlace-XOffscreen, YPlace+(YSize*2+YSpacer*2), MaxLength+XOffscreen, YSize, Color(0,0,0,255))
          draw.RoundedBox(0, XPlace, YPlace+(YSize*2+YSpacer*2)+border, (MaxLength-border)*DrawDefense, YSize-border*2, Color(200,0,0,222))

          surface.SetMaterial( gradient )
          surface.SetDrawColor(0, 0, 0, 255)
          surface.DrawTexturedRectRotated(MaxLength/2, YPlace+(YSize*3+YSpacer*3)-YSize/2-YSpacer, YSize, MaxLength, 90 )

          draw.DrawText("Agility: ".. agility, "TargetIDSmall", MaxLength/2, YPlace+(YSize*0+YSpacer*1), Color(255,255,255,255), 1)
          draw.DrawText("Acrobatics: ".. acrobatics, "TargetIDSmall", MaxLength/2, YPlace+(YSize*1+YSpacer*2), Color(255,255,255,255), 1)
          draw.DrawText("Defense: ".. defense, "TargetIDSmall", MaxLength/2, YPlace+(YSize*2+YSpacer*3), Color(255,255,255,255), 1)
          //draw.DrawText("Stats are experimental, don't freak out of they reset for any reason!", "TargetIDSmall", MaxLength+45, YPlace+(YSize*3+YSpacer*4), Color(255,255,255,255), 1)


     end

     hook.Add("HUDPaint", "statpainter", statsPaint)


     function updateStats()
          //print("fail")
          if not IsValid(LocalPlayer()) then print("fail") return end
          local statChoice = net.ReadString()
          
          if not LocalPlayer():GetTable().Playerstats then LocalPlayer():GetTable().Playerstats = blankPlayerstats end

          if statChoice == "all" then
               LocalPlayer():GetTable().Playerstats = net.ReadTable()

          elseif statChoice == "agility" then
               LocalPlayer():GetTable().Playerstats.agility = tonumber(net.ReadString())
               LocalPlayer():GetTable().Playerstats.agilityexp = tonumber(net.ReadString())

          elseif statChoice == "acrobatics" then
               LocalPlayer():GetTable().Playerstats.acrobatics = tonumber(net.ReadString())
               LocalPlayer():GetTable().Playerstats.acrobaticsexp = tonumber(net.ReadString())

          elseif statChoice == "barter" then
               LocalPlayer():GetTable().Playerstats.barter = tonumber(net.ReadString())
               LocalPlayer():GetTable().Playerstats.barterexp = tonumber(net.ReadString())

          elseif statChoice == "defense" then
               LocalPlayer():GetTable().Playerstats.defense = tonumber(net.ReadString())
               LocalPlayer():GetTable().Playerstats.defenseexp = tonumber(net.ReadString())

          elseif statChoice == "respect" then
               LocalPlayer():GetTable().Playerstats.respect = tonumber(net.ReadString())
          end
     end

     net.Receive("sendStats", updateStats)

     local time = CurTime()
     function GM:OnPlayerHitGround( ply, bInWater, bOnFloater, flFallSpeed )
          if ply != LocalPlayer() or not LocalPlayer():GetTable().Playerstats or time>CurTime()-0.2 then return end
          time=CurTime()
          LocalPlayer():GetTable().Playerstats.acrobaticsexp = LocalPlayer():GetTable().Playerstats.acrobaticsexp + 1
     end
     //hook.Add("OnPlayerHitGround", "handleJumpstatsys", OnPlayerHitGround)

     function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
          if ply != LocalPlayer() or not LocalPlayer():GetTable().Playerstats then return end
          LocalPlayer():GetTable().Playerstats.agilityexp = LocalPlayer():GetTable().Playerstats.agilityexp + 1
     end
     //hook.Add("PlayerFootstep", "runstatsyscl", PlayerFootstepcl)